package com.langfeiyes.pattern.proxy.dynamic.jdk;


public class App {
    public static void main(String[] args) {

        System.out.println("----------------真实对象--------------------");

        EmployeeServiceImpl employeeService = new EmployeeServiceImpl();
        employeeService.list();
        employeeService.save();

        System.out.println("----------------代理对象--------------------");
        SessionHolder.setCurrentUser("dafei");  //设置权限(当前登录用户)
        EmployeeInvocationHandler handler = new EmployeeInvocationHandler(employeeService);
        IEmployeeService proxy = (IEmployeeService) handler.getProxy();
        proxy.list();
        proxy.save();
    }
}
